package com.xtoneict;

import javax.script.Invocable;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import java.io.FileReader;
import java.nio.charset.StandardCharsets;

/**
 * <pre>
 * @TODO 描述文件用途
 * </pre>
 *
 * @author jew
 * @date 2024/3/13 11:49
 * @company 成都信通信息技术有限公司
 */
public class TestJs {

    public static void main(String[] args) throws Exception{
        ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
        ScriptEngine engine = scriptEngineManager.getEngineByName("JavaScript");
        /*engine.eval(new FileReader("C:\\Users\\62772\\Desktop\\test.js"));


        Invocable env = (Invocable) engine;
        Object testObject = engine.get("base64js");
        Object obj = env.invokeMethod(testObject, "toByteArray", "JavaCode");
        Object result = env.invokeMethod(testObject, "fromByteArray", "JavaCode".getBytes(StandardCharsets.UTF_8));
        System.out.println(testObject);
        System.out.println(result);
        System.out.println("=================================================");*/


        engine.eval(new FileReader("C:\\Users\\62772\\Desktop\\test1.js"));
        //Object testObject = engine.get("CaData_KXC");
        //System.out.println(testObject);

    }
}
